package com.lcf.system.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.lcf.framework.vo.PageVO;
import com.lcf.system.dto.MovieDTO;
import com.lcf.system.query.MoviePageQuery;
import com.lcf.system.query.MovieRecommendPageQuery;
import com.lcf.system.service.MovieService;
import com.lcf.system.vo.MovieListVO;
import com.lcf.system.vo.MovieVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 电影(Movie)表控制层
 *
 * @author lcf
 * @since 2025-05-07 22:23:21
 */
@Tag(name = "电影")
@RestController
@RequestMapping("movie")
public class MovieController {
    @Resource
    private MovieService movieService;

    /**
     * 新增
     */
    @Operation(summary = "新增电影")
    @SaCheckPermission("movie:add")
    @PostMapping
    public void add(@RequestBody @Validated MovieDTO dto) {
        movieService.add(dto);
    }

    /**
     * 编辑
     */
    @Operation(summary = "修改电影")
    @SaCheckPermission("movie:edit")
    @PatchMapping("{id}")
    public void edit(@PathVariable @Schema(description = "电影ID") long id,
                     @RequestBody @Validated MovieDTO dto) {
        movieService.edit(id, dto);
    }

    /**
     * 删除
     */
    @Operation(summary = "删除电影")
    @SaCheckPermission("movie:delete")
    @DeleteMapping("{id}")
    public void delete(@PathVariable @Schema(description = "电影ID") long id) {
        movieService.delete(id);
    }

    /**
     * 分页
     */
    @Operation(summary = "电影分页列表")
    @GetMapping("page")
    public PageVO<MovieListVO> page(MoviePageQuery query) {
        return movieService.page(query);
    }

    /**
     * 详情
     */
    @Operation(summary = "电影详情")
    @GetMapping("{id}")
    public MovieVO get(@PathVariable @Schema(description = "电影ID") long id) {
        return movieService.get(id);
    }

    /**
     * 电影推荐
     */
    @Operation(summary = "电影推荐")
    @GetMapping("recommend")
    public PageVO<MovieListVO> recommend(MovieRecommendPageQuery query) {
        return movieService.recommend(query);
    }
}

